﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using ExFlash.Editors;

namespace ExFlash.Records
{
    [Editor(typeof(RGBARecordEditor), typeof(UITypeEditor))]
    public class RGBABaseRecord : RGBRecord
    {
        public Byte Alpha
        {
            get;
            protected set;
        }

        static public explicit operator RGBABaseRecord(Color color)
        {
            return new RGBABaseRecord {Red = color.R, Green = color.G, Blue = color.B, Alpha = color.A};
        }

        public override Color GetColor()
        {
            return Color.FromArgb(Alpha, Red, Green, Blue);
        }
    }

    [Editor(typeof(RGBARecordEditor), typeof(UITypeEditor))]
    public class ARGBRecord : RGBABaseRecord
    {
        public override void SwfDeserialize(BinaryBitReader reader)
        {
            Alpha = reader.ReadByte();
            base.SwfDeserialize(reader);
        }
    }

    [Editor(typeof(RGBARecordEditor), typeof(UITypeEditor))]
    public class RGBARecord : RGBABaseRecord
    {
        public override void SwfDeserialize(BinaryBitReader reader)
        {           
            base.SwfDeserialize(reader);
            Alpha = reader.ReadByte();
        }
    }
}
